package DCSource.Template;

import java.io.IOException;
import java.util.ArrayList;
import DCSource.Template.Input.Transmitter;

public class ConsoleCMD {
	public ConsoleCMD(){
	}
	private ArrayList<Transmitter> values = new ArrayList<Transmitter>();
	private ConsoleCMD cmd = this;
	boolean on = false;
	private Thread work = new Thread(){
		public void run(){
			while(on){
				int b;
				try {
					String send = "";
					while ((b=System.in.read())!=13){
						if (b==10){
							break;
						}
						send+=String.valueOf((char) b);
					}
					for (int I=0;I<values.size();I++){
						values.get(I).get(send, cmd);
					}
				} catch (IOException e) {
					
				}
			}
		}
	};
	public void stop(){
		on=false;
	}
	public void start(){
		on=true;
		work.start();
	}
	public void add(Transmitter b){
		values.add(b);
	}
	public void rev(Transmitter b){
		values.remove(b);
	}
	public void writeln(String str){
		System.out.println(str);
	}
	public void write(String str){
		System.out.print(str);
	}
}
